<?php
class exercisepicture extends Model{
	
	/**
	 * 添加某习题下的图片
	 * @param unknown_type $eid
	 * @param unknown_type $pid
	 * @return Ambigous <boolean, number>
	 */
	public function addExercisePicture($eid,$pid)
	{
		$sql = "INSERT INTO `howdo`.`exercise_picture` (`ep_id`, `ex_id`, `pic_id`) VALUES (NULL, '".$eid."', '".$pid."');";
		//echo $sql;
		return $this->insert($sql);
	}
	
	/**
	 * 获取习题的图片
	 * @param unknown_type $eid
	 * @return Ambigous <boolean, multitype:>
	 */
	public function getExercisePicture($eid)
	{
		$sql = "SELECT `exercise_picture`.`pic_id`,`picture`.pic_link FROM `exercise_picture`
				LEFT JOIN `picture` ON `picture`.`pic_id`=`exercise_picture`.`pic_id` 
				WHERE `exercise_picture`.`ex_id` = '".$eid."' ";
		return $this->fetchAll($sql);
	}
	
	/**
	 * 删除习题下的图片
	 * @param unknown_type $eid
	 * @param unknown_type $pid
	 * @return resource
	 */
	public function delExercisePic($eid,$pid)
	{
		$sql = "DELETE FROM `exercise_picture` WHERE `ex_id`='".$eid."' AND `pic_id`='".$pid."'";
		//echo $sql;
		return $this->del($sql);
	}
}